<?php
require_once './component/head.php';
if (!isset($_SESSION['uid'])) header('Location:./login.php');
if ($_SESSION['utype'] != '管理员') header('Location:./center.php');
require_once './component/drawer.php';
require_once './function/conn.php';
//表格颜色配置
$i = 0;
?>
<script type="text/javascript">
    window.onload = function () {
        ManagementOnload();
    };
</script>
<div class="mdui-container mdui-center drxs-page">
    <div id="user_management">
        <div class="mdui-table-fluid drxs-radius">
            <table id="user_table" class="mdui-table mdui-table-hoverable">
                <thead>
                <tr class="<?php echo $_SESSION['table_color_1'] ?>">
                    <th>Uid</th>
                    <th>姓名</th>
                    <th>电子邮件</th>
                    <th>注册日期</th>
                    <th>所属学院</th>
                    <th>用户类型</th>
                </tr>
                </thead>
                <tbody>
                <?php
                if (!is_null($all_user = GetAllInfo('drxs_user'))) {
                    while ($user_info = mysqli_fetch_array($all_user)) {
                        if (($i++) % 2 == 0)
                            echo '<tr class=\'' . $_SESSION['table_color_2'] . '\'>';
                        else
                            echo '<tr class=\'' . $_SESSION['table_color_3'] . '\'>';
                        echo '<td>' . $user_info['Id'] . '</td>';
                        echo '<td>' . $user_info['Name'] . '</td>';
                        echo '<td>' . $user_info['Email'] . '</td>';
                        echo '<td>' . $user_info['Date'] . '</td>';
                        echo '<td>' . $user_info['College'] . '</td>';
                        echo '<td>' . $user_info['Type'] . '</td>';
                        echo '</tr>';
                    }
                } else {
                    echo '<tr class=\'' . $_SESSION['table_color_2'] . '\'>';
                    echo '<td colspan="6">很抱歉，当前查询的数据为空，请稍后再试！</td>';
                    echo '</tr>';
                }
                ?>
                </tbody>
            </table>
        </div>
        <button class="mdui-btn mdui-btn-raised mdui-ripple mdui-color-theme-accent">
            <a class="mdui-text-color-white">添加新用户</a>
        </button>
    </div>
    <div id="class_management">
        <div class="mdui-table-fluid drxs-radius">
            <table id="class_table" class="mdui-table mdui-table-hoverable">
                <thead>
                <tr class="<?php echo $_SESSION['table_color_1'] ?>">
                    <th>班级编号</th>
                    <th>班级名称</th>
                    <th>所属学院</th>
                    <th>备注信息</th>
                </tr>
                </thead>
                <tbody>
                <?php
                if (!is_null($all_class = GetAllInfo('drxs_class'))) {
                    while ($class_info = mysqli_fetch_array($all_class)) {
                        if (($i++) % 2 == 0)
                            echo '<tr class=\'' . $_SESSION['table_color_2'] . '\'>';
                        else
                            echo '<tr class=\'' . $_SESSION['table_color_3'] . '\'>';
                        echo '<td>' . $class_info['ClassId'] . '</td>';
                        echo '<td>' . $class_info['ClassName'] . '</td>';
                        echo '<td>' . $class_info['CollegeId'] . '</td>';
                        echo '<td>' . $class_info['Note'] . '</td>';
                        echo '</tr>';
                    }
                } else {
                    echo '<tr class=\'' . $_SESSION['table_color_2'] . '\'>';
                    echo '<td colspan="4">很抱歉，当前查询的数据为空，请稍后再试！</td>';
                    echo '</tr>';
                }

                ?>
                </tbody>
            </table>
        </div>
        <button class="mdui-btn mdui-btn-raised mdui-ripple mdui-color-theme-accent">
            <a class="mdui-text-color-white">添加新班级</a>
        </button>
    </div>
    <div id="college_management">
        <div class="mdui-table-fluid drxs-radius">
            <table id="college_table" class="mdui-table mdui-table-hoverable">
                <thead>
                <tr class="<?php echo $_SESSION['table_color_1'] ?>">
                    <th>学院编号</th>
                    <th>学院名称</th>
                    <th>备注信息</th>
                </tr>
                </thead>
                <tbody>
                <?php
                if (!is_null($all_college = GetAllInfo('drxs_college'))) {
                    while ($college_info = mysqli_fetch_array($all_college)) {
                        if (($i++) % 2 == 0)
                            echo '<tr class=\'' . $_SESSION['table_color_2'] . '\'>';
                        else
                            echo '<tr class=\'' . $_SESSION['table_color_3'] . '\'>';
                        echo '<td>' . $college_info['CollegeId'] . '</td>';
                        echo '<td>' . $college_info['CollegeName'] . '</td>';
                        echo '<td>' . $college_info['Note'] . '</td>';
                        echo '</tr>';
                    }
                } else {
                    echo '<tr class=\'' . $_SESSION['table_color_2'] . '\'>';
                    echo '<td colspan="3">很抱歉，当前查询的数据为空，请稍后再试！</td>';
                    echo '</tr>';
                }
                ?>
                </tbody>
            </table>
        </div>
        <button class="mdui-btn mdui-btn-raised mdui-ripple mdui-color-theme-accent">
            <a class="mdui-text-color-white">添加新学院</a>
        </button>
    </div>
    <div id="classroom_management">
        <div class="mdui-table-fluid drxs-radius">
            <table id="classroom_table" class="mdui-table mdui-table-hoverable">
                <thead>
                <tr class="<?php echo $_SESSION['table_color_1'] ?>">
                    <th>教室编号</th>
                    <th>教室名称</th>
                    <th>备注信息</th>
                </tr>
                </thead>
                <tbody>
                <?php
                if (!is_null($all_classroom = GetAllInfo('drxs_classroom'))) {
                    while ($classroom_info = mysqli_fetch_array($all_classroom)) {
                        if (($i++) % 2 == 0)
                            echo '<tr class=\'' . $_SESSION['table_color_2'] . '\'>';
                        else
                            echo '<tr class=\'' . $_SESSION['table_color_3'] . '\'>';
                        echo '<td>' . $classroom_info['ClassroomId'] . '</td>';
                        echo '<td>' . $classroom_info['ClassroomName'] . '</td>';
                        echo '<td>' . $classroom_info['Note'] . '</td>';
                        echo '</tr>';
                    }
                } else {
                    echo '<tr class=\'' . $_SESSION['table_color_2'] . '\'>';
                    echo '<td colspan="3">很抱歉，当前查询的数据为空，请稍后再试！</td>';
                    echo '</tr>';
                }
                ?>
                </tbody>
            </table>
        </div>
        <button class="mdui-btn mdui-btn-raised mdui-ripple mdui-color-theme-accent">
            <a class="mdui-text-color-white">添加新教室</a>
        </button>
    </div>
</div>
<?php require_once './component/footer.php'; ?>
